package com.school.information.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class CustomRequestMatcherConfig {
    @Autowired
    private IgnoreRequestConfig ignoreRequestConfig;

    @Bean
    public RequestMatcher[] requestMatchers() {
        List<RequestMatcher> requestMatcherList = new ArrayList<>();
        ignoreRequestConfig.getUrl().forEach(path -> requestMatcherList.add(new AntPathRequestMatcher(path)));
        return requestMatcherList.toArray(new RequestMatcher[0]);
    }
}
